package cn.niitcxl.utils;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回前端统一对象
 */
@Data
public class R {
    private Boolean flag;
    private String message;
    private Map<String,Object> data = new HashMap<>();

    public R(){}

    public R ok(){
        R r = new R();
        r.setFlag(true);
        r.setMessage("成功!");
        return r;
    }

    public R error(){
        R r = new R();
        r.setFlag(false);
        r.setMessage("失败");
        return r;
    }

    public R message(String message){
        this.message= message;
        return this;
    }

    public R data(String key,Object data){

        this.data.put(key,data);
        return this;
    }

    public R data(HashMap<String,Object> data){

        this.data=data;
        return this;
    }



}